package bean;

public class Check_Bean {

    private String[] name_admin;
    private String[] password;
    private String[] id_admin;
    private int jumlahData = 0;

    /**
     * Creates a new instance of BinLogin
     */
    public Check_Bean() {
        name_admin = new String[100];
        password = new String[100];
        id_admin = new String[100];
    }

    public String getId(int n) {
        return id_admin[n];
    }

    public void setId(String id_admin, int n) {
        this.id_admin[n] = id_admin;
    }

    public String getNameAdmin(int a) {
        return name_admin[a];
    }

    public void setNameAdmin(String name_admin, int a) {
        this.name_admin[a] = name_admin;
    }

    public String getPassword(int a) {
        return password[a];
    }

    public void setPassword(String Password, int a) {
        this.password[a] = Password;
    }

    public void login() {
        DataBaseConnection conn = new DataBaseConnection();
        try {
            String query = "select * from PENGGUNA";
            java.sql.Statement statement = conn.getConnection().createStatement();
            java.sql.ResultSet result = statement.executeQuery(query);
            int n = -1;
            while (result.next()) {
                n++;
                setId(result.getString("id_user"), n);
                setNameAdmin(result.getString("user_name"), n);
                setPassword(result.getString("password_user"), n);
                //setJabatan(result.getString("jabatan"),n);
            }
            statement.close();
        } catch (Exception ex) {
            System.out.println("message: " + ex.getMessage());
        }
    }

    public static void main(String args[]) {
        DataBaseConnection tst = new DataBaseConnection();
        Check_Bean cb = new Check_Bean();
        cb.login();
        //int i = -1;
       for(int i = 0; i < 3; i++) {
            //n++;
            System.out.println(cb.getId(i) + "\n");
            System.out.println(cb.getNameAdmin(i) + "\n");
            System.out.println(cb.getPassword(i) + "\n");
        }
    }
}
